package com.geek.javase.ch07.strings;

/*
 *@author wangpeng
 *2025/10/15 16:09
 *@description TODO
 */

//练习3：判断一个字符串是否是对称字符串。 例如"abc"不是对称字符串，"aba"、"abba"、"aaa"、"mnanm"是对称字符串

import java.util.Scanner;

public class StringBuilderDemo5 {
    public static boolean isSymmetric(String str) {
        StringBuilder sb  = new StringBuilder(str);
        StringBuilder reverse = sb.reverse();
        String s= reverse.toString();
        return  str.equals(s);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");

        String str = sc.nextLine();
        if(isSymmetric(str)){
            System.out.println(str+"是对称字符串");
        }else{
            System.out.println(str + "不是对称字符串");
        }
    }
}
